$(document).ready(function () {

    $("#captchaImg").click(function () {
        var timestamp = new Date().getTime();
        $(this).attr('src', '/api/0/findVerifyCode?t=' + timestamp);
    });

    //$("#submit").click(login);
    $("form").submit(login);

    function login() {
        var name = $("#name").val();
        var pass = $("#pass").val();
        var verify = $("#verify").val();
        var formData = {
            name: name,
            pass: pass,
            verify: verify
        };
        var url = '/api/0/acctLogin';
        var method = 'POST';
        $.ajax({
            type: method,
            url: url,
            data: formData,
            dataType: "json",
            success: function (data, textStatus, jqXHR) {
                console.log(data);
                console.log(textStatus);
                console.log(jqXHR);
                alert(data.body);
                if (data.head) {
                    //
                } else {
                    $("#pass").val("");
                    $("#verify").val("");
                    $("#captchaImg").attr('src', '/api/0/findVerifyCode?t=' + new Date().getTime());
                }
            },
            error: function () {

            }
        });
    };
});